package com.vvip.tool.time;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.TimeZone;

public class TimeZoneTest2 {

    public static void main(String[] args) {
        TimeZone newYork = TimeZone.getTimeZone("America/New_York"); //GMT-5
        System.out.println(newYork);

        System.out.println();
        TimeZone timeZone = TimeZone.getDefault();
        System.out.println(timeZone);

        TimeZone york = TimeZone.getTimeZone("America/New_York");

        // 纽约当地时间
        LocalDateTime now = LocalDateTime.now(ZoneId.of("America/New_York"));
        System.out.println(now);

        System.out.println();
        // 获取指定时区的当前时间
        LocalDateTime time = LocalDateTime.now(ZoneId.of("America/New_York"));
        // 时区
        ZoneId zoneId = ZoneId.of("America/New_York");
        // 带时区的时间
        ZonedDateTime of = ZonedDateTime.of(time, zoneId);
        System.out.println(of.getOffset().getId());

    }
}
